package com.haojg.service;


import java.util.function.Function;

public class MockWeatherService implements Function<MockWeatherService.WeatherRequest, MockWeatherService.WeatherResponse> {

    public record WeatherRequest(String location, String unit) {

    }

    public record WeatherResponse(double temperature, String description) {

    }


    @Override
    public WeatherResponse apply(WeatherRequest weatherRequest) {
        int temperature = weatherRequest.location.contains("深圳") ? 20 : 25;
        return new WeatherResponse(temperature, weatherRequest.unit);
    }
}
